CURR_FILE_PATH:=$(abspath $(lastword $(MAKEFILE_LIST)))
CURR_DIR:=$(shell dirname $(CURR_FILE_PATH))
-include $(CURR_DIR)/../../ag35cet_sdk/ql-sdk/sdk.mk

export QL_SAMPLE_DIR=$(QL_SDK_DIR)/sample
export QL_TARGET_DIR=$(QL_SDK_DIR)/target
export QL_OEMAPP_DIR=$(QL_SDK_DIR)/oemapp
export QL_OEMDATA_DIR=$(QL_SDK_DIR)/oemdata
export QL_TOOLS_DIR=$(QL_SDK_DIR)/tools
export QL_TOOLS_CONF_DIR=$(QL_SDK_DIR)/tools/conf

JOBS=$(shell cat /proc/cpuinfo | grep processor | wc -l)

.PHONY:all
all:   kernel_module 



############################################################################################
#                                     build kernel                                         #
############################################################################################
KERNELDIR:=/home/gui/6818GEC/kernel
CROSS_COMPILE:=/home/gui/6818GEC/prebuilts/gcc/linux-x86/arm/arm-eabi-4.8/bin/arm-eabi-
#/home/gui/6818GEC/kernel
obj-m := ledmodule.o
kernel_module: 
	$(MAKE) -C /home/gui/6818GEC/kernel ARCH=arm CROSS_COMPILE=$(CROSS_COMPILE)  M=$(PWD) modules -j$(JOBS)
	arm-linux-gcc *.cpp -o main

#	$(MAKE) -C $(QL_KERNEL_DIR) M=$(CURDIR) ARCH=$(QL_ARCH) CROSS_COMPILE=$(QL_CROSSTOOLS_PREFIX) -j$(JOBS) modules
#	make ARCH=$(QL_ARCH) CROSS_COMPILE=$(QL_CROSSTOOLS_PREFIX) 
#	make -C $(QL_KERNEL_DIR) ARCH=$(QL_ARCH) CROSS_COMPILE=$(QL_CROSSTOOLS_PREFIX) -j$(JOBS) modules

#	make -C $(QL_KERNEL_DIR) ARCH=$(QL_ARCH) CROSS_COMPILE=$(QL_CROSSTOOLS_PREFIX) INSTALL_MOD_STRIP=1 INSTALL_MOD_PATH=$(QL_ROOTFS_DIR) modules_install

.PHONE:clean

clean:
	$(MAKE) -C $(KERNELDIR) M=$(CURR_DIR) clean
	rm main

